<template>
    <div>
        <section class="content-header">
            <h1>
                审核状态
                <small>audit state</small>
            </h1>
        </section>
        <section class="content">
            <Card style="width:100%;margin-bottom: 16px;">
                <p slot="title">审核状态</p>
                <div>
                    <i-switch size="large" :true-value="1" :false-value="0" v-model="switch1" @on-change="change">
                    </i-switch>
                    <span v-if="switch1" style="color:#2d8cf0;margin-left:16px">审核中...</span>
                </div>
            </Card>
        </section>
    </div>
</template>
<script>
import apis from "@/api/admin";
export default {
    data() {
        return {
            switch1: 0,
        };
    },
    created() {
        this.set_audit_state();
    },
    methods: {
        set_audit_state() {
            apis.set_audit_state().then(response => {
                if (response.data.code == 200) {
                    this.switch1 = response.data.data.a_state;
                } else {
                    this.$Message.error('请求错误')
                }
            }).catch(error => {
                console.log(error)
                this.loading = false;
                this.$Message.error('请求错误!');
            })
        },
        change(val) {
            console.log(val)
            apis.change_audit_state({ a_state: val }).then(response => {
                if (response.data.code == 200) {
                    this.$Message.success('改修成功');
                } else {
                    this.$Message.error('请求错误')
                }
            }).catch(error => {
                console.log(error)
                this.loading = false;
                this.$Message.error('请求错误!');
            })
        }
    }
};
</script>
<style>
</style>